//part1:C03:ex3.42.cpp -- copy a vector to an int array.
#include <iostream>
#include <vector>
#include <ctime>
#include <cstdlib>

int main(void)
{
    using namespace std;
    const int sz = 10;
    vector<int> v1;
    srand((unsigned)time(NULL));
    cout << "vector is:" << endl;
    for (int i = 0; i != sz; ++i)
    {
        v1.push_back(rand() % 100);    
        cout << v1[i] << " ";
    }
    cout << endl;
    auto it = v1.cbegin();
    int a[v1.size()];
    cout << "array is:" << endl;
    for (auto &val : a)
    {
        val = *it;
        cout << val << " ";
        it++;
    }
    cout << endl;
    return 0;
}
